<?php
/**
 * TomatoCMS
 *
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 *
 * @copyright    Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license        http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version     $Id: _browser.phtml 4194 2010-08-01 16:34:06Z huuphuoc $
 * @since        2.0.4
 */
?>
<?php
$this->headLink()
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.core.css')
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.resizable.css')
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.dialog.css')
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.theme.css');

$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.core.js')
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.draggable.js')
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.resizable.js')
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.dialog.js');
?>

<div>
    <?php echo sprintf($this->translator('file_browse', 'upload'), '<a href="javascript: void(0);" id="libLoader_'.$this->counter.'">', '</a>'); ?>
    <div id="libLoaderContainer_<?php echo $this->counter; ?>"></div>
</div>

<script type="text/javascript">
$(document).ready(function() {
    var dialogOpts_<?php echo $this->counter; ?> = {
        title: "<?php echo $this->escape($this->translator('file_browse_title', 'upload')); ?>",
        modal: true,
        autoOpen: false,
        height: 500,
        width: 500,
        open: function() {
            $('#libLoaderContainer_<?php echo $this->counter; ?>').load('<?php echo $this->url(array(), 'upload_file_browse'); ?>', {
                    path: '<?php echo $this->path; ?>',
                    imageSelectCallback: '<?php echo $this->imageSelectCallback; ?>',
                    ext: '<?php echo $this->ext; ?>',
            });
        }
    };
    $('#libLoaderContainer_<?php echo $this->counter; ?>').dialog(dialogOpts_<?php echo $this->counter; ?>);

    $('#libLoader_<?php echo $this->counter; ?>').click(function() {
        $("#libLoaderContainer_<?php echo $this->counter; ?>").dialog('open');
    });
});
</script>
